package org.neuedu.chapter04_0616;

public class Practice08 {
    public static void main(String[] args) {
        // 给定一维数组{ -10,2,3,246,-100,0,5} ,计算出数组中的平均值、最大值、最小值。
        int[] arr = {-10, 2, 3, 246, -100, 0, 5};
        int max = arr[0];
        int min = arr[0];
        int index1 = 0;
        int index2 = 0;
        double sum = 0;
        int i = 0;
        for (int num : arr) {
            sum = sum + num;
            if (num > max) {
                max = num;
                index1 = i;
            }
            if (num < min) {
                min = num;
                index2 = i;
            }
            i++;
        }
        System.out.println(sum / arr.length);
        System.out.println(max + "," + index1);
        System.out.println(min + "," + index2);
    }
}
